#include <iostream>
using namespace std;

#define MaxSize 25

typedef struct 
{
    int data[MaxSize];
    int length = 0;
} S_IntList;

typedef struct 
{
    int *data;
    int length, ListSize;
} D_IntList;

bool insertList(D_IntList &L, int index, int n)
{
    if (L.length >= L.ListSize || index < 0)
        return false;
        
    if (L.length < index) L.data[L.length] = n;
    else{
        for (int i = L.length; i >= index; i--)  swap(L.data[i],L.data[i+1]);
        L.data[index] = n;
    }
    L.length++;
    return true;
}

bool delList(D_IntList &L, int index)
{
    if (L.length < 1 || index>L.length)
        return false;
    index = index<0? L.length-index+1 : index;
    for (int i = index; i <= L.length; i++)
    swap(L.data[i],L.data[i+1]);
    L.length--;

    return true;
}

int findList(D_IntList &L,int num){
    int index = 0;
    for (index = 0; index < L.length; index++)
    {
       if (L.data[index] == num) break;
    }
    return index;
}

D_IntList init(){
    D_IntList L;
    L.data = new int[MaxSize];
    L.length = 0;
    L.ListSize = MaxSize;
    return L;
}
D_IntList init2(){
    D_IntList L;
    // L.data;
    L.length = 0;
    L.ListSize = MaxSize;
    return L;
}

int main(int argc, char const *argv[])
{
    D_IntList list1 = init();
    // list1.data[1]=20;
    // list1.data[0]=20;
    insertList(list1,2,1);
    insertList(list1,0,2);
    insertList(list1,2,3);
    delList(list1,1);
    int findx =  findList(list1,3);
    return 0;
}
